﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Async_await.DAL;
using Async_await.Entity;

namespace Async_await.Controllers
{
    public class HomeController : Controller
    {


        public ActionResult Index()
        {
            var linq = from data1 in new UserDAL().GetEntities<User>()
                    //   join data2 in new User_ProfileDAL().GetModel() on data1.ID equals data2.ID
                       select data1;
            ViewBag.Message = "欢迎使用 ASP.NET MVC!";
            return View(linq.ToList());
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult Create()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Create(Entity.User entity)
        {
            if (ModelState.IsValid)   
            {
                new UserDAL().Insert(entity);
                return RedirectToAction("Index");
            }
            return View();
        }
    }
}
